<?php 
class Db_model extends PDO { 
     
    private $engine; 
    private $host; 
    private $database; 
    private $user; 
    private $pass; 
     
    public function __construct(){ 
        $this->engine = 'mysql'; 
        $this->host = 'localhost'; 
        $this->database = 'test2'; 
        $this->user = 'root'; 
        $this->pass = ''; 
        $dns = $this->engine.':dbname='.$this->database.";host=".$this->host; 
        parent::__construct( $dns, $this->user, $this->pass ); 
    }
     
     
    public function get_data($page=NULL){
      $query = 'SELECT * FROM `blocks`';
      $items_per_page=5;
        if($items_per_page != null){
            if($page == null){
                $page = 1;
            }
            $limit = " LIMIT ".($page-1)*$items_per_page." , ".$items_per_page;
        }
        else $limit="";
 
        $sth = parent::prepare($query.$limit);
        if(!$sth->execute()){
            $result = array(1=>'false',2=>"There was an error in sql syntax.");
            return $result;
        }
        $result = $sth->fetchAll();
        return $result;
    }
}